package com.lanou.dao.impl;

import com.lanou.bean.Designer;
import com.lanou.dao.DesignerDao;
import com.lanou.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class DesignerDaoImpl implements DesignerDao {

    private Connection connection;
    private PreparedStatement pstm;
    @Override
    public void insertInfo(Designer designer) throws Exception {
        String sql = "INSERT INTO designer (d_id, d_designerPhoto, d_designerName, d_position, d_idea, d_designerData, d_companyId) VALUES (?,?,?,?,?,?,?)";

        connection = JDBCUtils.getConnection();
        pstm = connection.prepareStatement(sql);

        pstm.setInt(1,designer.getId());
        pstm.setString(2,designer.getPhoto());
        pstm.setString(3,designer.getName());
        pstm.setString(4,designer.getPosition());
        pstm.setString(5,designer.getIdea());
        pstm.setString(6,designer.getDesignerData());
        pstm.setInt(7,designer.getCompanyId());

        pstm.executeUpdate();
        JDBCUtils.close(pstm,connection);
    }
}
